package org.querycreator.core;

import java.io.Serializable;

import org.querycreator.operator.EqualsOperator;
import org.querycreator.operator.GreaterAndEqualsThanOperator;
import org.querycreator.operator.GreaterThanOperator;
import org.querycreator.operator.NotEqualsOperator;
import org.querycreator.operator.Operator;

/**
 * 
 * 
 * @author Luciano Molinari
 *
 */
public class Restriction implements Serializable {
	private static final long serialVersionUID = 4452116815697346207L;

	private String fieldName;
	private Object fieldValue;
	private Operator operator;
	
	private Restriction(String fieldName, Object fieldValue, Operator operator) {
		this.fieldName = fieldName;
		this.fieldValue = fieldValue;
		this.operator = operator;;
	}
	
	public static Restriction equals(String field, Object value) {
		return new Restriction(field, value, new EqualsOperator());
	}
	
	public static Restriction notEquals(String field, Object value) {
		return new Restriction(field, value, new NotEqualsOperator());
	}
	
	public static Restriction greaterThan(String field, Object value) {
		return new Restriction(field, value, new GreaterThanOperator());
	}
	
	public static Restriction greaterAndEqualsThan(String field, Object value) {
		return new Restriction(field, value, new GreaterAndEqualsThanOperator());
	}	
	
	public String getFieldName() {
		return fieldName;
	}
	
	public Object getFieldValue() {
		return fieldValue;
	}
	
	public Operator getOperator() {
		return operator;
	}
	
}